import {
    AppOutline,
    MessageOutline,
    UnorderedListOutline,
    UserOutline,
} from 'antd-mobile-icons'
import { lazy } from 'react'
import { createBrowserRouter } from 'react-router-dom'
import MainLayout from '../pages/mainLayout/MainLayout'
import Login from '../pages/login/Login'
import Register from '../pages/register/Register'
import Detail from '../pages/detail/Detail'
import Error from '../pages/error/Error'
import City from '../pages/city/City'
import Cartlist from '../pages/cartlist/Cartlist'

let Home = lazy(() => import('../pages/home/Home'))
let Message = lazy(() => import('../pages/message/Message'))
let Props = lazy(() => import('../pages/props/Props'))
let User = lazy(() => import('../pages/user/User'))

export let homerouters = [
    {
        path: '/',
        element: <Home></Home>,
        title: '首页',
        icon: <AppOutline></AppOutline>
    },
    {
        path: '/mainLayout/messgae',
        element: <Message></Message>,
        title: '消息',
        icon: <MessageOutline></MessageOutline>
    },
    {
        path: '/mainLayout/props',
        element: <Props></Props>,
        title: '分类',
        icon: <UnorderedListOutline></UnorderedListOutline>
    },
    {
        path: '/mainLayout/user',
        element: <User></User>,
        title: '个人中心',
        icon: <UserOutline></UserOutline>
    },
]
let routers = createBrowserRouter(
    [
        {
            path: '/',
            element: <MainLayout></MainLayout>,
            children: homerouters
        },
        {
            path: '/login',
            element: <Login></Login>,
        },
        {
            path: '/register',
            element: <Register></Register>,
        },
        {
            path: '/detail',
            element: <Detail></Detail>,
        },
        {
            path: '/city/:type',
            element: <City></City>,
        },
        {
            path: '/cartlist',
            element: <Cartlist></Cartlist>,
        },
        {
            path: '*',
            element: <Error></Error>,
        },
    ]
)
export default routers